from biz.mysql.io.BaseSql import sql


class Dk_knrdxs(sql):

    def __init__(self):
        super().__init__()
        self.SERVICE_NAME = '贷款困难认定'
        self.groupby=' yxm,dwmc '
        self.metric='dwmc'

    def unique_sql(self, where) -> str:
        sql='''
        select t.*,
        case 
        when (select xh from T_KNS where xn='2022-2023' and xq=2 and xh=t.xh) is null 
        then 0 
        else 1 end num 
        from T_ZXDK t WHERE xn='2022-2023' and xq=2
        '''
        print(">>>>>{}.{}>>>{}".format(self, 'unique_sql', sql))
        return sql
